﻿@using System.Security.Claims
@inherits EntitesGridModel<Entity.UserClaim>

<EntitiesGrid Items="@Claims" TableClass="table table-hover" Context="claim">
    <TableHeader>
        <th scope="col">
            <SortableHeader Property="ClaimType"
                            Text="@Localizer["type"]"
                            GridState="GridState" />
        </th>
        <th scope="col">
            <SortableHeader Property="ClaimValue"
                            Text="@Localizer["value"]"
                            GridState="GridState" />
        </th>
        <th scope="col">
            <SortableHeader Property="Issuer"
                            Text="@Localizer["issuer"]"
                            GridState="GridState" />
        </th>
        <th></th>
    </TableHeader>
    <RowTemplate>
        @if (string.IsNullOrEmpty(claim.Issuer) || claim.Issuer == ClaimsIdentity.DefaultIssuer)
        {
            <td>
                <AuthorizeText @bind-Value="@claim.ClaimType" MaxLength="250" />
            </td>
            <td>
                <AuthorizeText @bind-Value="@claim.ClaimValue" />
            </td>
        }
        else
        {
            <td>
                <div>@claim.ClaimType</div>
                @if (claim.OriginalType != null)
                {
                    <em class="small text-secondary">from: @claim.OriginalType</em>
                }
            </td>
            <td>
                @claim.ClaimValue
            </td>
        }
        <td>
            @claim.Issuer
        </td>
        <td>
            <AuthorizeButton Type="button" CssSubClass="btn-primary" Clicked="() => OnDeleteClaimClicked(claim)">
                <span class="oi oi-trash"></span>
            </AuthorizeButton>
        </td>
    </RowTemplate>
</EntitiesGrid>
